home *** CD-ROM | disk | FTP | other *** search
- REM *************** Text Window Scroll Bar(s) Example ********************
- REM *** ZBasic 3.05 or Greater (public domain) 1/87 A.G ZEDCOR, INC. ***
- REM *** with modifications & explainations 2/87 by D. Kelly MacTutor™ ***
- REM **********************************************************************
- WINDOW OFF
- COORDINATE WINDOW
- WIDTH -2
- False = 0 : True = NOT False
- X=MEM(-1) :REM *** Disable Line Wrap ***
- WINDOW 1,"Untitled",(50,50)-(450,255),9 : REM ** Initial Window Size **
- TEXT 4,9
- MENU 1,0,1,"File"
- MENU 1,1,1,"Open"
- MENU 1,2,0,"-"
- MENU 1,3,1,"Quit"
- MENU 2,0,1,"Scroll Type"
- MENU 2,1,1,"Normal Scroll"
- MENU 2,2,1,"Soft Scroll"
- DIM Ascent,Descent,WidMax,Leading
- CALL GETFONTINFO(Ascent)
- Height=Ascent+Descent+Leading :REM * Font Size *
- GOSUB "Openfile"
- OV=False
- OH=True
- Softscroll=False : REM **** Softscroll = Soft-Scroll Flag ****
- SCROLL BUTTON 1,OV,OV,TL-1,TL/10,,1
- SCROLL BUTTON 2,OH,OH,255,10,,2
- ON DIALOG GOSUB "Dialog"
- ON MENU GOSUB "MenuEvent"
- WINDOW#1,A$ : REM *** File name to Title ***
- DIALOG ON
- MENU ON
- BREAK ON : REM **> Var 'Softscroll' 0=Normal Scroll 1=Soft Scroll **
- "Loop" : GOTO "Loop" : REM *** Main Event Trapping Loop ***
- DIALOG OFF: BREAK OFF :MENU OFF: REM *** Turn OFF dialogs for rest of PGM ***
- "MenuEvent"
- Menunumber = MENU(0)
- Menuitem = MENU(1)
- LONG IF Menunumber = 1
- IF Menuitem = 1 THEN GOSUB "Openfile"
- IF Menuitem = 3 THEN STOP
- END IF
- IF Menuitem = 1 THEN Softscroll = 0 ELSE Softscroll = 1
- MENU
- RETURN
- "Dialog" : D=DIALOG(0) : REM **** Dialog Events come here.. ****
- ON D GOTO "Button","X","ACTIVE","GoAway","Update","X","X","Zoom","Zoom"
- "ACTIVE"
- WINDOW #DIALOG(D)
- RETURN : REM ** Activate this Window **
- "Button"
- IF DIALOG(D)=1 THEN Buttonvalue=BUTTON(1) ELSE "Side"
- X=OV-Buttonvalue
- IF ABS(X) > SL THEN OV=Buttonvalue : CLS : GOTO "Update"
- IF X>0 THEN DV=Height :DL=-1 :Leading=0 :P=Ascent ELSE DV=-Height :DL=+1 :Leading=SL+1 :P=(SL-1)*Height+Ascent
- WHILE OV<>Buttonvalue
- IF Softscroll THEN DV=SGN(DV) : II=1 ELSE II=Height
- FOR II=II TO Height : REM **** If THIS LINE if Soft-Scroll Not used *****
- SCROLL (0,0)-(W6,W7),,DV : REM ***** SCROLL 1 line or 1 Pixel *****
- PRINT %(-BUTTON(2)*WidMax,P+(DV*(II-Height)));INDEX$(OV-1+Leading);
- NEXT
- OV=OV+DL : REM **** Remove NEXT if soft-scroll not used ***
- WEND : RETURN
- "Zoom"
- CLS : RETURN : REM ***** ERASE IF ZOOM-IN OR ZOOM OUT *****
- "Side"
- SCROLL(0,0)-(W6,W7),(OH-BUTTON(2))*WidMax,0:OH=BUTTON(2)
- "Update"
- W6=WINDOW(6)-1 : W7=WINDOW(7)-1 : SL=W7/Height
- FOR II= OV TO OV+SL-1 : REM ******* Re-Draw Full Screen *******
- PRINT %(-BUTTON(2)*WidMax,(II-OV)*Height+Ascent);INDEX$(II);
- NEXT
- COLOR 0 :BOX FILL 0,SL*Height TO W6,W7 :COLOR -1 :REM *Erase Bottom*
- "X"
- RETURN : REM **** Just RETURN routine ****
- "GoAway"
- STOP
- "Openfile" : A$=FILES$(1,"TEXT",,V%)
- IF A$="" THEN BEEP : STOP ELSE CLS
- OPEN "I",#1,A$,1,V%
- CLEAR LOF(1)+32
- TL=0
- IF MEM=0 THEN STOP
- WHILE NOT EOF(1) : REM ******> Read TEXT file into INDEX$ array <*******
- LINEINPUT#1,W$
- INDEX$(TL)=W$
- TL=TL+1 : REM FILL INDEX$ FROM FILE
- WEND
- CLOSE
- RETURN
- REM ***********************************************************************
- REM ** Some Possible Changes: **
- REM ** Line 210 Change 'ABS(X) > SL' to 'ABS(X) > 1' Single Line Soft **
- REM ** Add 'CLEAR 0' to Erase INDEX$ Array When Text Window Closed. **
- REM ***********************************************************************
-